import json
import os
from typing import Any


def write_json(file: str, json_obj: Any):
    """
    写入json到文件
    Args:
        file: 文件路径
        json_obj: json对象
    """
    parent = os.path.dirname(file)
    if not os.path.exists(parent):
        os.makedirs(parent)
    with open(file, 'w', encoding='utf-8') as f:
        f.write(json.dumps(json_obj))


def write_json1(dest_dir: str, filename: str, json_obj: Any):
    """
    写入json到文件
    Args:
        dest_dir: 目标文件夹
        filename: 文件名称
        json_obj: json对象
    """
    write_json(os.path.join(dest_dir, filename), json_obj)
